//
//  STPriceView.m
//  CuiBoStore
//
//  Created by 崔博 on 16/12/13.
//  Copyright © 2016年 崔博. All rights reserved.
//

#import "STPriceView.h"

@interface STPriceView()
@property (nonatomic, strong) UILabel *totalLabel;
@property (nonatomic, strong) UILabel *pariceLabe;
@property (nonatomic, strong) UILabel *baoyouLabel;
@property (nonatomic, strong) UIButton *coluBtn;
@end
@implementation STPriceView
- (instancetype)initWithFrame:(CGRect)frame
{
    if (self  = [super initWithFrame:frame]) {
        self.backgroundColor = [UIColor whiteColor];
        [self addSubviews];
    }
    return self;
}
#pragma mark - event
- (void)addSubviews
{
    [self addSubview:self.totalLabel];
    [self addSubview:self.pariceLabe];
    [self addSubview:self.baoyouLabel];
    [self addSubview:self.coluBtn];
    
    [_totalLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(@10);
        make.left.equalTo(@12);
        make.height.equalTo(@15);
    }];
    
    [_pariceLabe mas_makeConstraints:^(MASConstraintMaker *make) {
        MASONRY(left, _totalLabel.mas_right, 8);
        MASONRY(top, _totalLabel, 0);
    }];
    [_baoyouLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.right.equalTo(_pariceLabe.mas_right);
        make.bottom.equalTo(@(-10));
    }];
    [_coluBtn mas_makeConstraints:^(MASConstraintMaker *make) {
        make.right.equalTo(@(-15));
        make.centerY.equalTo(self);
        make.height.equalTo(@35);
        make.width.equalTo(@110);
    }];
    
    [self layoutIfNeeded];
}

- (void)payMoney
{
    if (self.block) {
        self.block();
    }
}

#pragma mark - set
- (void)setPrice:(NSString *)price
{
    _price = price;
    self.pariceLabe.text = price;
}
#pragma mark - lazy
- (UILabel *)totalLabel
{
    if (!_totalLabel) {
        _totalLabel = [STUIKitTools labelFont:14];
        _totalLabel.text = @"合计:";
    }
    return _totalLabel;
}
- (UILabel *)pariceLabe
{
    if (!_pariceLabe) {
        _pariceLabe = [STUIKitTools lableFont:17 textColor:[UIColor redColor]];
        _pariceLabe.text = @"￥100";
    }
    return _pariceLabe;
}
- (UILabel *)baoyouLabel
{
    if (!_baoyouLabel) {
        _baoyouLabel = [STUIKitTools lableFont:12 textColor:[UIColor lightGrayColor] text:@"(全场包邮)"];
    }
    return _baoyouLabel;
}
- (UIButton *)coluBtn
{
    if (!_coluBtn) {
        _coluBtn = [STUIKitTools buttonTitle:@"去结算" font:15 action:@selector(payMoney) titleColor:[UIColor whiteColor] target:self];
        _coluBtn.backgroundColor = [UIColor blueColor];
        _coluBtn.layer.cornerRadius = 2;
    }
    return _coluBtn;
}
@end
